package com.ruoyi.certificate.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.certificate.domain.NjtInspection;
import com.ruoyi.certificate.service.INjtInspectionService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 农检通工作平台检查记录Controller
 * 
 * @author ruoyi
 * @date 2025-03-05
 */
@RestController
@RequestMapping("/certificate/njt_inspection")
public class NjtInspectionController extends BaseController
{
    @Autowired
    private INjtInspectionService njtInspectionService;

    /**
     * 查询农检通工作平台检查记录列表
     */
    @PreAuthorize("@ss.hasPermi('certificate:njt_inspection:list')")
    @GetMapping("/list")
    public TableDataInfo list(NjtInspection njtInspection)
    {
        startPage();
        List<NjtInspection> list = njtInspectionService.selectNjtInspectionList(njtInspection);
        return getDataTable(list);
    }

    /**
     * 导出农检通工作平台检查记录列表
     */
    @PreAuthorize("@ss.hasPermi('certificate:njt_inspection:export')")
    @Log(title = "农检通工作平台检查记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, NjtInspection njtInspection)
    {
        List<NjtInspection> list = njtInspectionService.selectNjtInspectionList(njtInspection);
        ExcelUtil<NjtInspection> util = new ExcelUtil<NjtInspection>(NjtInspection.class);
        util.exportExcel(response, list, "农检通工作平台检查记录数据");
    }

    /**
     * 获取农检通工作平台检查记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('certificate:njt_inspection:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(njtInspectionService.selectNjtInspectionById(id));
    }

    /**
     * 新增农检通工作平台检查记录
     */
    @PreAuthorize("@ss.hasPermi('certificate:njt_inspection:add')")
    @Log(title = "农检通工作平台检查记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody NjtInspection njtInspection)
    {
        return toAjax(njtInspectionService.insertNjtInspection(njtInspection));
    }

    /**
     * 修改农检通工作平台检查记录
     */
    @PreAuthorize("@ss.hasPermi('certificate:njt_inspection:edit')")
    @Log(title = "农检通工作平台检查记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody NjtInspection njtInspection)
    {
        return toAjax(njtInspectionService.updateNjtInspection(njtInspection));
    }

    /**
     * 删除农检通工作平台检查记录
     */
    @PreAuthorize("@ss.hasPermi('certificate:njt_inspection:remove')")
    @Log(title = "农检通工作平台检查记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(njtInspectionService.deleteNjtInspectionByIds(ids));
    }
}
